#!/usr/bin/env python
# encoding: utf-8
# @author: LANG
import time

from common.base_bo import Browser


class CHROME(Browser):

    # CHROME 浏览器特有的属性 , 最大化

    MAX_WINDOW = "--start-maximized"
    # Chrome浏览器实验性质属性

    EP = {

        'excludeSwitches':['enable-automation'],  # 仅仅一条，浏览器不再出现。xx正在被控制的提示
        # "mobileEmulation": {
        #         #
        #         #     "deviceName": "iPhone 6"
        #         # }
    }

    @property
    def options(self):
        chrome_options = self._browser_option() # 创建options对象
        chrome_options.add_argument(self.MAX_WINDOW)
        for k , v in self.EP.items():
            chrome_options.add_experimental_option(k, v)

        return chrome_options

    @property
    def browser(self):
        _chrome =  self._browser_type(executable_path=self._driver_path ,options=self.options) # 创建chrome浏览器对象
        _chrome.implicitly_wait(self.IMP_TIME)
        return _chrome
    # 不要覆盖父类的init方法吗？


# class FIREFOX(Browser):
#
#
#
#     def __init__(self) -> None:
#         super().__init__(driver_path= settings.FIREFOX_DRIVER_PATH, browser_type= Firefox  , browser_option=FirefoxOptions)
#
#     @property
#     def options(self):
#         super().options()
#
#     @property
#     def browser(self):
#         super().browser()


# # 简单测试
#
# with CHROME().browser as _driver:
#
#     _driver.get(url= "http://192.168.10.45/#/home")
#
#     time.sleep(4)



